﻿using winS.UnityEditor.Undo;

namespace winS.UnityEditor.ProcessEditor
{
    public class DisconnectNodeCommand : IUndoCommand
    {
        public string info => "断开节点连接";

        private readonly InputPort inputPort;
        private readonly OutputPort outputPort;
        private readonly StepGraphView stepGraphView;
        private readonly Connectionline connectionline;

        public DisconnectNodeCommand(Connectionline connectionline, StepGraphView stepGraphView)
        {
            this.stepGraphView = stepGraphView;
            this.connectionline = connectionline;
            inputPort = connectionline.inputPort;
            outputPort = connectionline.outputPort;
        }

        public void Redo()
        {
            connectionline.Disconnect();
            stepGraphView.RemoveConnectionline(connectionline);
        }
        public void Undo()
        {
            connectionline.Connect(inputPort, outputPort);
            stepGraphView.AddConnectionline(connectionline);
        }
    }
}